perm filename PROB5.PUB[LSP,JRA]1 blob sn#084472 filedate 1974-01-30 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	.SS(Problems)
C00004 ENDMK
C⊗;
.SS(Problems)
.BEGIN CENTERIT;TABIT2(10,23);SELECT 1;
.GROUP
I  Use the following defintion:
%3
\match[k;m] <=\[null[k] → NO;
\\ null[m] → NO;
\\ eq[car[k];car[m]] → car[k];
\\ T → match[cdr[k];cdr[m]]]

%1
and evaluate:
%21.%3 match[(X);(X)]   %22.%3 match[(A B E);(J O E)]  %23.%3 match[(F O O); (BAZ)]
.APART
%1
.GROUP

II  Now write your own.
.FILL

%21.%3 among[x;y] <= ... : among%1 is to be a predicate; %3x%1 is an atom; %3y%1 is a list
of atoms.  %3among%1 is to return %3NIL%1 if %3x%1 is not found as an element of %3y%1; o.w.
among is to return %3T%1.

.NOFILL
\e.g. %3among[A;(A B C)] = among[A;(C D E A)] = T
\     among[A1;(A2 B2)] = NIL.
.FILL
%1

%22.%3 anywhere[x;y] <= ... : anywhere%1 is a predicate; %3x%1 is an atom; %3y%1 is an arbitrary
sexpr. %3anywhere%1 is to return %3T%1 just in the case that %3x%1 appears somewhere in %3y%1.
.NOFILL

\e.g. %3anywhere[A;(A B C)] = anywhere[A;((A . B). C)] = T
\     anywhere[A;(B C D)] = NIL.
.FILL
%1

.END